<template>
  <div>
    <div v-if="!detailsType">
      <div class="radio">
        <el-radio-group v-model="PatentType" size="mini" @change="radioUpdate">
          <el-radio-button label="0">商标总数 {{PatentNumber.trade}}</el-radio-button>
          <el-radio-button label="1">国内商标 {{PatentNumber.trade_cn}}</el-radio-button>
          <el-radio-button label="2">海外商标 {{PatentNumber.trade_seas}}</el-radio-button>
        </el-radio-group>
      </div>

      <el-table :data="trademarkList" style="width: 100%" :header-cell-style="{ background: '#F3F8FE' }"
        @row-click="trademarkClick">
        <el-table-column prop="fd" label="申请日期">
          <template slot-scope="scope">
            {{ scope.row.fd | time }}
          </template>
        </el-table-column>
        <el-table-column prop="tmog" label="商标">
          <template slot-scope="scope">
            <el-image :src="scope.row.tmsg" fit="cover">
            </el-image>
          </template>
        </el-table-column>
        <el-table-column prop="mno" label="商标名称">
        </el-table-column>
        <el-table-column prop="rn" label="注册号">
        </el-table-column>
        <el-table-column prop="mk" label="商标类型">
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination background @current-change="handleCurrentChange" :current-page="page" :page-size="limit"
          layout="total, prev, pager, next, jumper" :total="Number(count)" align="left"></el-pagination>
      </div>
    </div>
    <div v-else>
      <el-descriptions class="margin-top" :column="2" border>
        <template slot="extra">
          <el-button type="primary" size="small" @click="detailsType = false">返回</el-button>
        </template>
        <el-descriptions-item label="商标" :span="2" :labelStyle="{}">
          <el-image :src="data.tmog" fit="fill" style="width: 150px;">
          </el-image>
        </el-descriptions-item>
        <el-descriptions-item :span="2" label="商标名称">
          {{ data.mno }}
        </el-descriptions-item>
        <el-descriptions-item label="注册号">
          {{ data.rn }}
        </el-descriptions-item>
        <el-descriptions-item label="商标类型">
          {{ data.mk }}
        </el-descriptions-item>
        <el-descriptions-item label="申请日期">
          {{ data.fd }}
        </el-descriptions-item>
        <el-descriptions-item label="注册日期">
          {{ data.rd }}
        </el-descriptions-item>
        <el-descriptions-item label="申请人名称">
          {{ data.hno }}
        </el-descriptions-item>
        <el-descriptions-item label="代理人名称">
          {{ data.aro }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<script>
import {
  trademarklist,companynum
} from "@/api/newuser"
export default {
  data() {
    return {
      PatentType: '0',
      detailsType: false,
      data: {
        
      },
      index: 0,
      page: 1,
      limit: 10,
      count: 0,
      trademarkList: [{
        tid: '商标主键id',
        mno: '商标名称',
        nc: '尼斯分类',
        cs: '权利状态',
        mk: '商标类型',
        tmog: '图形',
        rn: '注册号',
        tmsg: '图形缩略图',
        rd: '注册日期',
        sn: '申请号',
        fd: '申请日期',
        hno: '申请人名称(原文)',
        aro: '代理人名称(原文)',
        hnado: '申请人地址(原文)',
        hnac: '申请人区域代码',
        tmdb: '数据库来源'
      }],
    }
  },
  filters: {
    //时间戳转换
    time(date) {
      // if (val) {
      //   return new Date(val).toLocaleString()
      // }
      date = new Date(date)
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? ('0' + m) : m;
      var d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      return y + '-' + m + '-' + d;
    }
  },
  watch: {
    'form_admin.company': {
      handler(newV, oldV) {
        this.trademarklist();
      },
      deep: true
    }
  },
  props: {
    form_admin: {
      type: Object,
      default: () => ({})
    },
    PatentNumber:{
      type: Object,
      default: () => ({})
    },
  },
  components: {},
  mounted() {
    this.trademarklist();
  },
  methods: {
    radioUpdate(){
      this.trademarklist();
    },
    trademarkClick(row, column, event) {
      this.num = row.id
      this.trademarklist()
      this.detailsType = true
    },
    trademarklist() {
      trademarklist({
        company: this.form_admin.company,
        page: this.page,
        limit: this.limit,
        num: this.num,
        type: Number(this.PatentType)
      }).then(res => {
        if (this.detailsType) {
          this.data = res
        } else {
          this.trademarkList = res.list
          this.count = res.count
        }
      })
    },
    handleCurrentChange(page) {
      this.page = page
      this.trademarklist()
    },
  },
};
</script>

<style scoped lang="less">
::v-deep .el-drawer__header {
  margin-bottom: 20px;
  display: none;
}
.pagination {
  margin: 10px auto;
}
::v-deep .radio {

.el-radio-group {
  .el-radio-button {
    margin: 5px 0;
    span {
      border-left: 1px solid #DCDFE6;
    }
  }
}
}
::v-deep .card_v .el-card__body {
  min-height: 1050px;
  padding: 0;

  .el-tabs .el-tabs__content {
    padding: 0 20px;

    tr th {
      font-size: 16px;
    }

    tr td {
      font-size: 16px;
    }
  }
}

.trademark {
  padding: 12px 0;

  .logo {}

  ._text {
    height: 105px;

    .el-row {
      height: 100%;
      display: flex;
      justify-content: space-between;
      flex-direction: column;

      .title_t {
        display: flex;
        justify-content: space-between;

      }

      .title_b {
        font-size: 12px;
      }
    }

  }
}

// ::v-deep .v_tabs .el-tabs__header .el-tabs__nav .el-tabs__item {
//   padding: 0 20px !important;
// }



@media (max-width: 1360px) {}

@media (max-width: 1280px) {}

@media (max-width: 768px) {}
</style>
